import { useReducer } from "react";
/* reducer和context结合实现vuex的功能 */
const useMyReducer = ()=>{
    const initState = {
        count:0
    }
    const reducer = (state,action)=>{
         if(action.type==="increase"){
             return {
                 count:state.count+1
             }
         }else{
             return state
         }
    }
    const [state,dispatch] = useReducer(reducer,initState);
    return [state,dispatch];
}
export default useMyReducer;